﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Follow.Common;
using Follow.Model;
using Follow.DataAccess;
using System.Transactions;

namespace Follow.Business
{
    public class PropostaBO
    {

        public IList<Proposta> findAll()
        {
            PropostaDAO dao = new PropostaDAO();
            return dao.findAll();
        }

        public void delete(Int32 id, Int32 idlogin)
        {
            PropostaDAO dao = new PropostaDAO();
            dao.delete(id, idlogin);
        }

        public void update(Int32 idproposta, double valorTotal, double desconto, Int32 idlogin)
        {
            PropostaDAO dao = new PropostaDAO();
            dao.update(idproposta, valorTotal, desconto, idlogin);
        }

        public void updateProposta(Proposta p, Int32 idlogin)
        {
            PropostaDAO dao = new PropostaDAO();
            dao.updateProposta(p, idlogin);
        }

        public int save(Proposta p, Int32 idlogin)
        {
            int idProposta = 0;
            PropostaDAO dao = new PropostaDAO();

            if (p.IDProposta == Int32.MinValue || p.IDProposta.Equals(0))
            {
                idProposta = dao.insert(p, idlogin);
            }

            return idProposta;
        }

        public void deleteProposta(Int32 id, Int32 idUsuario)
        {
            PropostaDAO dao = new PropostaDAO();
            dao.delete(id, idUsuario);
        }
    }
}